const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const cors = require('koa2-cors');
const json = require('koa-json');
const abnormal = require('./config/abnormal');
const router = require('./router/router')
const login = require('./router/login/login.js');
const userinfo = require('./router/user-info/userinfo.js');

const app = new Koa();
app.use(cors());
app.use(json());
app.use(bodyParser());
// 全局异常处理

app.use(abnormal);

router.use('/api', login)
router.use('/api', userinfo)
/*启动路由*/
app.use(router.routes()).use(router.allowedMethods())

// 启动服务，监听端口号4000
app.listen(4000)
console.log('服务启动，监听4000端口--------------------------------------------------------------------')
